package com.sjl.utils;

import org.apache.commons.lang3.StringUtils;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

/**
 * Created by wings on 2016/7/29.
 */
public class SimpleFactoryCache {

    public static ConcurrentHashMap<Class,Field[]> map=new ConcurrentHashMap<Class,Field[]>();



    public static Field[] getFiles(Class className){
        Field[] fields=null;
        if(map.get(className)==null){
            map.put(className,className.getDeclaredFields());
        }
        fields= map.get(className);

        return fields;
    }

    public static List<Class<?>> getsuperClass(Class<?> calzz){
        List<Class<?>> listSuperClass = new ArrayList<Class<?>>();
        Class<?> superclass = calzz.getSuperclass();
        while (superclass != null) {
            if(StringUtils.equals(superclass.getName(),"java.lang.Object")){
                break;
            }
            listSuperClass.add(superclass);
            superclass = superclass.getSuperclass();
        }
        return listSuperClass;
    }


}
